import { Link, withRouter, useHistory } from "react-router-dom";
import routes from "@/zhihuPages";
import { useSearch } from "@/hooks";

export default (props) => {
  const history = useHistory();
  const { id } = useSearch();

  const headerClick = (index) => {
    history.replace(`${routes[index].children[0].path}?id=${index}`);
  };
  return (
    <div className="header">
      {routes.map((ele, index) => (
        <span
          key={ele.id}
          className={id == index ? "on" : ""}
          onClick={() => headerClick(index)}
        >
          {ele.text}
        </span>
      ))}
    </div>
  );
};
